From 25bfd14834675d4bc5cc38295787526481396b93 Mon Sep 17 00:00:00 2001
From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
Date: Sun, 13 Aug 2023 05:40:00 -0600
Subject: [PATCH] adjust greatcircle conversion factors, kill gcgeodist cheat.
(#1156)
* tweak greatcircle conversions.
* modify arc-project test to use microdegrees instead of nanodegrees.
* kill unused metric prefix conversion macros.
---
defs.h | 5 -
grtcirc.h | 6 +-
reference/arc-project1.csv | 3 +
reference/arc-project1.gpx | 265 ---------------------------------
reference/arc-project2.csv | 5 +
reference/arc-project2.gpx | 277 ----------------------------------
reference/arc-project3.csv | 7 +
reference/arc-project3.gpx | 294 -------------------------------------
reference/garmin_txt.txt | 34 ++---
testo.d/arc-project.test | 18 +--
waypt.cc | 7 +-
11 files changed, 46 insertions(+), 875 deletions(-)
create mode 100644 reference/arc-project1.csv
delete mode 100644 reference/arc-project1.gpx
create mode 100644 reference/arc-project2.csv
delete mode 100644 reference/arc-project2.gpx
create mode 100644 reference/arc-project3.csv
delete mode 100644 reference/arc-project3.gpx
diff --git a/defs.h b/defs.h
index d5b2c47e9..7f0f1dd0a 100644
--- a/defs.h
+++ b/defs.h
@@ -115,11 +115,6 @@ constexpr double MPH_TO_MPS(double a) { return a * kMPSPerMPH;}
/* knots(nautical miles/hour) to meters/second */
constexpr double KNOTS_TO_MPS(double a) {return a * kMPSPerKnot;}
-#define MILLI_TO_MICRO(t) ((t) * 1000) /* Milliseconds to Microseconds */
-#define MICRO_TO_MILLI(t) ((t) / 1000) /* Microseconds to Milliseconds*/
-#define CENTI_TO_MICRO(t) ((t) * 10000) /* Centiseconds to Microseconds */
-#define MICRO_TO_CENTI(t) ((t) / 10000) /* Centiseconds to Microseconds */
-
constexpr int kDatumOSGB36 = 86; // GPS_Lookup_Datum_Index("OSGB36")
constexpr int kDautmWGS84 = 118; // GPS_Lookup_Datum_Index("WGS 84")
diff --git a/grtcirc.h b/grtcirc.h
index ae094e40f..70641f183 100644
--- a/grtcirc.h
+++ b/grtcirc.h
@@ -45,9 +45,11 @@ void linepart(double lat1, double lon1,
double* reslat, double* reslon);
/* Degrees to radians */
-constexpr double DEG(double x) { return (x) * 180.0 / M_PI; }
+constexpr double kDegreesPerRadian = 180.0 / M_PI;
+constexpr double DEG(double x) { return x * kDegreesPerRadian; }
/* Radians to degrees */
-constexpr double RAD(double x) { return (x) * M_PI / 180.0; }
+constexpr double kRadiansPerDegree = 1.0 / kDegreesPerRadian;
+constexpr double RAD(double x) { return x * kRadiansPerDegree; }
#endif
diff --git a/reference/arc-project1.csv b/reference/arc-project1.csv
new file mode 100644
index 000000000..e8a4ec539
--- /dev/null
+++ b/reference/arc-project1.csv
@@ -0,0 +1,3 @@
+No,Latitude,Longitude,Name,Symbol
+1,28.356662,-16.497183,"wpt2","flag, red"
+2,28.357407,-16.501378,"wpt3","flag, green"
diff --git a/reference/arc-project1.gpx b/reference/arc-project1.gpx
deleted file mode 100644
index e8465b3a9..000000000
--- a/reference/arc-project1.gpx
+++ /dev/null
@@ -1,265 +0,0 @@
-
-
-
-
-
- wpt2
- wpt2
- wpt2
- flag, red
-
-
- wpt3
- wpt3
- wpt3
- flag, green
-
-
- Route1
-
- RPT001
-
-
- RPT002
-
-
- RPT003
-
-
- RPT004
-
-
- RPT005
-
-
- RPT006
-
-
- RPT007
-
-
- RPT008
-
-
- RPT009
-
-
- RPT010
-
-
- RPT011
-
-
- RPT012
-
-
- RPT013
-
-
- RPT014
-
-
- RPT015
-
-
- RPT016
-
-
- RPT017
-
-
- RPT018
-
-
- RPT019
-
-
- RPT020
-
-
- RPT021
-
-
- RPT022
-
-
- RPT023
-
-
- RPT024
-
-
- RPT025
-
-
- RPT026
-
-
- RPT027
-
-
- RPT028
-
-
- RPT029
-
-
- RPT030
-
-
-
- Track1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/arc-project2.csv b/reference/arc-project2.csv
new file mode 100644
index 000000000..c169dd2dc
--- /dev/null
+++ b/reference/arc-project2.csv
@@ -0,0 +1,5 @@
+No,Latitude,Longitude,Name,Symbol
+1,28.358827,-16.501228,"wpt1","flag, green"
+2,28.354380,-16.495831,"wpt4","flag, green"
+3,28.353926,-16.496775,"wpt5","flag, green"
+4,28.358987,-16.499790,"wpt6","flag, green"
diff --git a/reference/arc-project2.gpx b/reference/arc-project2.gpx
deleted file mode 100644
index 4044be1bb..000000000
--- a/reference/arc-project2.gpx
+++ /dev/null
@@ -1,277 +0,0 @@
-
-
-
-
-
- wpt1
- wpt1
- wpt1
- flag, green
-
-
- wpt4
- wpt4
- wpt4
- flag, green
-
-
- wpt5
- wpt5
- wpt5
- flag, green
-
-
- wpt6
- wpt6
- wpt6
- flag, green
-
-
- Route1
-
- RPT001
-
-
- RPT002
-
-
- RPT003
-
-
- RPT004
-
-
- RPT005
-
-
- RPT006
-
-
- RPT007
-
-
- RPT008
-
-
- RPT009
-
-
- RPT010
-
-
- RPT011
-
-
- RPT012
-
-
- RPT013
-
-
- RPT014
-
-
- RPT015
-
-
- RPT016
-
-
- RPT017
-
-
- RPT018
-
-
- RPT019
-
-
- RPT020
-
-
- RPT021
-
-
- RPT022
-
-
- RPT023
-
-
- RPT024
-
-
- RPT025
-
-
- RPT026
-
-
- RPT027
-
-
- RPT028
-
-
- RPT029
-
-
- RPT030
-
-
-
- Track1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/arc-project3.csv b/reference/arc-project3.csv
new file mode 100644
index 000000000..fcf9aa6c5
--- /dev/null
+++ b/reference/arc-project3.csv
@@ -0,0 +1,7 @@
+No,Latitude,Longitude,Name,Symbol,Date,Time
+1,28.357846,-16.499208,"Derecha","right",2011/09/26,00:00:51
+2,28.359546,-16.502867,"LAP001","Waypoint",2011/09/26,00:00:00
+3,28.355463,-16.500421,"Valle","valley",2011/09/26,00:02:22
+4,28.359197,-16.501778,"wpt1","flag, green",2011/09/26,00:00:13.732
+5,28.354172,-16.497408,"wpt5","flag, green",2011/09/26,00:03:09
+6,28.358886,-16.500621,"wpt6","flag, green",2011/09/26,00:00:28.528
diff --git a/reference/arc-project3.gpx b/reference/arc-project3.gpx
deleted file mode 100644
index b31797513..000000000
--- a/reference/arc-project3.gpx
+++ /dev/null
@@ -1,294 +0,0 @@
-
-
-
-
-
-
- Derecha
- Derecha
- Derecha
- right
-
-
-
- LAP001
- LAP001
- LAP001
-
-
-
- Valle
- Valle
- Valle
- valley
-
-
-
- wpt1
- wpt1
- wpt1
- flag, green
-
-
-
- wpt5
- wpt5
- wpt5
- flag, green
-
-
-
- wpt6
- wpt6
- wpt6
- flag, green
-
-
- Route1
-
- RPT001
-
-
- RPT002
-
-
- RPT003
-
-
- RPT004
-
-
- RPT005
-
-
- RPT006
-
-
- RPT007
-
-
- RPT008
-
-
- RPT009
-
-
- RPT010
-
-
- RPT011
-
-
- RPT012
-
-
- RPT013
-
-
- RPT014
-
-
- RPT015
-
-
- RPT016
-
-
- RPT017
-
-
- RPT018
-
-
- RPT019
-
-
- RPT020
-
-
- RPT021
-
-
- RPT022
-
-
- RPT023
-
-
- RPT024
-
-
- RPT025
-
-
- RPT026
-
-
- RPT027
-
-
- RPT028
-
-
- RPT029
-
-
- RPT030
-
-
-
- Track1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/garmin_txt.txt b/reference/garmin_txt.txt
index 888817c3f..0bf346b12 100644
--- a/reference/garmin_txt.txt
+++ b/reference/garmin_txt.txt
@@ -3,25 +3,25 @@ Datum WGS 84
Header Name Description Type Position Altitude Depth Proximity Temperature Display Mode Color Symbol Facility City State Country Date Modified Link Categories
-Waypoint 001 Map Line N50 29.556188732 E12 06.325848140 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint 002 Map Intersection N50 29.556188732 E12 06.325848140 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint 003 Map Intersection N50 29.656610638 E12 06.307823695 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint 004 Map Line N50 29.630036652 E12 06.366030984 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint 005 Map Line N50 29.630036652 E12 06.366030984 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint 006 Map Intersection N50 29.602537304 E12 06.426270045 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint 007 Map Line N50 29.619586095 E12 06.429106481 Symbol Unknown Waypoint 28/03/2006 00:10:37
-Waypoint ED_X Dummy airport (Germany) Airport N51 53.627961650 E12 58.676564991 Symbol & Name Unknown Airport FAC1 CITY1 Germany (civil) 28/03/2006 01:38:07
-Waypoint GC_X Dummy airport (Spain) Airport N38 37.919719778 W3 10.443304181 Symbol & Name Unknown Airport FAC2 CITY2 Spain (Canary Islands) 28/03/2006 01:42:01
-Waypoint Jahnstrasse Jahnstrasse 11 User Waypoint N50 29.619998485 E12 06.429000869 Symbol & Description Unknown Flag, Red 31/03/2006 21:48:22
-Waypoint LF_X Dummy airport (France) Airport N46 23.256332763 E3 29.896638617 Symbol & Name Unknown Airport FAC3 CITY3 France (Metropolitan France; including Saint-Pierre and Miquelon) 28/03/2006 01:40:32
-Waypoint LI_X Dummy airport (Italy) Airport N43 18.873018846 E12 09.693240859 Symbol & Name Unknown Heliport FAC4 CITY4 Italy 28/03/2006 01:43:25
-Waypoint Liebknechtstrasse Liebknechtstrasse 90 User Waypoint N50 29.630041681 E12 06.366015896 Symbol & Name Unknown Waypoint 31/03/2006 21:49:30
+Waypoint 001 Map Line N50 29.556188732 E12 06.325848140 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint 002 Map Intersection N50 29.556188732 E12 06.325848140 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint 003 Map Intersection N50 29.656610638 E12 06.307823695 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint 004 Map Line N50 29.630036652 E12 06.366030984 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint 005 Map Line N50 29.630036652 E12 06.366030984 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint 006 Map Intersection N50 29.602537304 E12 06.426270045 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint 007 Map Line N50 29.619586095 E12 06.429106481 Symbol Unknown Waypoint 28/03/2006 00:10:37
+Waypoint ED_X Dummy airport (Germany) Airport N51 53.627961650 E12 58.676564991 Symbol & Name Unknown Airport FAC1 CITY1 Germany (civil) 28/03/2006 01:38:07
+Waypoint GC_X Dummy airport (Spain) Airport N38 37.919719778 W3 10.443304181 Symbol & Name Unknown Airport FAC2 CITY2 Spain (Canary Islands) 28/03/2006 01:42:01
+Waypoint Jahnstrasse Jahnstrasse 11 User Waypoint N50 29.619998485 E12 06.429000869 Symbol & Description Unknown Flag, Red 31/03/2006 21:48:22
+Waypoint LF_X Dummy airport (France) Airport N46 23.256332763 E3 29.896638617 Symbol & Name Unknown Airport FAC3 CITY3 France (Metropolitan France; including Saint-Pierre and Miquelon) 28/03/2006 01:40:32
+Waypoint LI_X Dummy airport (Italy) Airport N43 18.873018846 E12 09.693240859 Symbol & Name Unknown Heliport FAC4 CITY4 Italy 28/03/2006 01:43:25
+Waypoint Liebknechtstrasse Liebknechtstrasse 90 User Waypoint N50 29.630041681 E12 06.366015896 Symbol & Name Unknown Waypoint 31/03/2006 21:49:30
Waypoint NARVA Start User Waypoint N50 29.556958191 E12 06.326884143 391 m Symbol Unknown Flag, Green 31/03/2006 21:49:26 http://www.narva-light.de Category 15
Header Name Length Course Waypoints Link
-Route ED_X-LF_X 4087 km 232° true 4 waypoints
+Route ED_X-LF_X 4087 km 232° true 4 waypoints
Header Waypoint Name Distance Leg Length Course
@@ -30,7 +30,7 @@ Route Waypoint GC_X 1936 km 1936 km 227
Route Waypoint LI_X 3323 km 1388 km 63° true
Route Waypoint LF_X 4087 km 764 km 300° true
-Route NARVA to Jahnstrasse 394 m 46° true 10 waypoints
+Route NARVA to Jahnstrasse 394 m 46° true 10 waypoints
Header Waypoint Name Distance Leg Length Course
@@ -41,14 +41,14 @@ Route Waypoint 003 189 m 188 m 353
Route Waypoint 004 274 m 85 m 126° true
Route Waypoint Liebknechtstrasse 274 m 0 m 298° true
Route Waypoint 005 274 m 0 m 118° true
-Route Waypoint 006 361 m 88 m 126° true
+Route Waypoint 006 362 m 88 m 126° true
Route Waypoint 007 393 m 32 m 6° true
Route Waypoint Jahnstrasse 394 m 1 m 351° true
Header Name Start Time Elapsed Time Length Average Speed Link
-Track ACTIVE LOG 006 01/05/2005 15:02:47 0:33:09 653 m 1.2 kph
+Track ACTIVE LOG 006 01/05/2005 15:02:47 0:33:09 653 m 1.2 kph
Header Position Time Altitude Depth Temperature Leg Length Leg Time Leg Speed Leg Course
diff --git a/testo.d/arc-project.test b/testo.d/arc-project.test
index 21408321f..d916ecba2 100644
--- a/testo.d/arc-project.test
+++ b/testo.d/arc-project.test
@@ -5,18 +5,18 @@
rm -f ${TMPDIR}/arc-project*
# Test 1: rte & trk options
-gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x arc,rte,exclude,distance=0.1K -x arc,trk,exclude,distance=0.1K -o gpx -F ${TMPDIR}/arc-project1.gpx
-compare ${REFERENCE}/arc-project1.gpx ${TMPDIR}/arc-project1.gpx
+gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x arc,rte,exclude,distance=0.1K -x arc,trk,exclude,distance=0.1K -o unicsv,utc -F ${TMPDIR}/arc-project1.csv
+compare ${REFERENCE}/arc-project1.csv ${TMPDIR}/arc-project1.csv
# Test 2: rte, project & points options
-gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x arc,rte,project,points,distance=0.1K -o gpx -F ${TMPDIR}/arc-project2.gpx
-compare ${REFERENCE}/arc-project2.gpx ${TMPDIR}/arc-project2.gpx
+gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x arc,rte,project,points,distance=0.1K -o unicsv,utc -F ${TMPDIR}/arc-project2.csv
+compare ${REFERENCE}/arc-project2.csv ${TMPDIR}/arc-project2.csv
# Test 3: trk & project options
-gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x arc,trk,project,distance=0.1K -o gpx -F ${TMPDIR}/arc-project3.gpx
-compare ${REFERENCE}/arc-project3.gpx ${TMPDIR}/arc-project3.gpx
+gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x arc,trk,project,distance=0.1K -o unicsv,utc -F ${TMPDIR}/arc-project3.csv
+compare ${REFERENCE}/arc-project3.csv ${TMPDIR}/arc-project3.csv
# Test 4: Verify that filter names aren't case sensistive. (Actually has
-# nothing specific to arc...)
-gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x ArC,trk,project,distance=0.1K -o gpx -F ${TMPDIR}/arc-project3.gpx
-compare ${REFERENCE}/arc-project3.gpx ${TMPDIR}/arc-project3.gpx
+# nothing specific to arc...)
+gpsbabel -i gpx -f ${REFERENCE}/arc-project.gpx -x ArC,trk,project,distance=0.1K -o unicsv,utc -F ${TMPDIR}/arc-project3.csv
+compare ${REFERENCE}/arc-project3.csv ${TMPDIR}/arc-project3.csv
diff --git a/waypt.cc b/waypt.cc
index f2bce6128..30b255c73 100644
--- a/waypt.cc
+++ b/waypt.cc
@@ -225,12 +225,7 @@ double
gcgeodist(const double lat1, const double lon1,
const double lat2, const double lon2)
{
- double res = radtometers(gcdist(RAD(lat1), RAD(lon1), RAD(lat2), RAD(lon2)));
- if (res < 0.1) {
- res = 0; /* calc. diffs on 32- and 64-bit hosts */
- }
-
- return res;
+ return radtometers(gcdist(RAD(lat1), RAD(lon1), RAD(lat2), RAD(lon2)));
}
/*
--
2.30.2